require('../../assets/css/index.js')

require('./sport.less')
require('../../assets/iconfonts/iconfont.css')


let dom = require('../../utils/dom')
let http = require('../../utils/http')
let Swiper = require('../../utils/swiper-bundle.min')

dom.ready(function () {
    dom.Foot('sport')
    let Boxs = dom.getAllEl('.Box')
    let Cards = dom.getAllEl('.showBox')
    // 选项卡

    for (let a = 0; a < Boxs.length; a++) {
        Boxs[a].onclick = function () {
            for (let b = 0; b < Boxs.length; b++) {
                Boxs[b].classList.remove('bdr')
                Cards[b].classList.remove('show')
            }
            Boxs[a].classList.add('bdr')
            Cards[a].classList.add('show')
        }
    }


    http.get('/api/train/courseList', {}, function (res) {
        if (res.errno == 0) {
            console.log(res);
            res.data.forEach(function (el) {
                if (el.courseId == 1) {
                    ClassBox.innerHTML = `
                    <div class = "Bigbox">
                        <a href="Nav.html" class = "Bigbox">
                            <div class="Newclass">最新课程</div>
                                <div class="Navbox">
                                    <img src="${http.baseURL + el.imgurl}" alt="">
                                    <h5>${el.name}</h5>
                                    <p>${el.desc}</p>
                                </div>
                            </a>
                        </div>
                            `
                }
                else if(el.courseId == 2) {
                    ClassBox.innerHTML += `
                    <div class = "Bigbox">
                        <a href="Nav.html">
                            <div class="Newclass">课程</div>
                                <div class="Navbox">
                                    <img src="${http.baseURL + el.imgurl}" alt="">
                                    <h5>${el.name}</h5>
                                    <p>${el.desc}</p>
                                </div>
                                </a>
                                </div>
                            `
                }else{
                    ClassBox.innerHTML += `
                    <div class = "Bigbox">
                        <a href="Nav.html">
                                <div class="Navbox">
                                    <img src="${http.baseURL + el.imgurl}" alt="">
                                    <h5>${el.name}</h5>
                                    <p>${el.desc}</p>
                                </div>
                                </a>
                                </div>
                            `
                }
            });

        }
    })
})